//
//  ShellSettingCell.m
//  ShellWallert
//
//  Created by lvzhao on 2019/9/26.
//  Copyright © 2019年 VV. All rights reserved.
//

#import "ShellSettingCell.h"
#import "ShellSettingModel.h"

@interface ShellSettingCell()
//图片
@property (nonatomic,strong) UIImageView *headImageView;

//titlelabel
@property (nonatomic,strong) UILabel *titleLabel;

@property (nonatomic,strong) UILabel *detailLabel;

@end
@implementation ShellSettingCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = UIColorHex(0x031D32);
        [self setupView];
    }
    return self;
}


#pragma mark - setupView
- (void)setupView{
    
    //title
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(20);
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(18);
    }];
    
    
    //detail
    [self.contentView addSubview:self.detailLabel];
    [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.right.mas_equalTo(-30);
        make.left.mas_equalTo(self.titleLabel.mas_right).mas_offset(10);
        make.height.mas_equalTo(18);
    }];
    
    
    //headImageView
    [self.contentView addSubview:self.headImageView];
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.right.mas_equalTo(-20);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(60);
    }];
    
    self.bottomLineView.hidden = NO;

}


#pragma mark - actions

#pragma mark - custool

#pragma mark - get && set
- (void)setModelObject:(id)modelObject{
    ShellSettingModel *settingModel = modelObject;
    
    self.headImageView.hidden = YES;
    self.rightImageView.hidden = YES;
    self.detailLabel.hidden = YES;

    switch (self.indexPath.row) {
        case 0:        {
            self.headImageView.hidden = NO;
        }
            break;
        case 1:        {
            self.rightImageView.hidden = NO;
            self.detailLabel.hidden = NO;
        }
            break;
        case 2:        {
            self.detailLabel.hidden = NO;
        }
            break;
            
        default:
            break;
    }

    self.titleLabel.text = settingModel.title;
    self.detailLabel.text = settingModel.detail;
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:settingModel.imageUrl] placeholderImage:k_imageName(@"default_headportrait")];
}

- (UIImageView *)headImageView{
    if (!_headImageView) {
        _headImageView = [[UIImageView alloc] init];
        _headImageView.cornerRadius = 30;
    }
    return _headImageView;
}

//title
- (UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = UIColorHex(0xDBCFC3);
        _titleLabel.font = k_textFont(14);
        _titleLabel.numberOfLines = 2;
    }
    return _titleLabel;
}

//title
- (UILabel *)detailLabel{
    if(!_detailLabel){
        _detailLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0x678DA8) font:k_textFont(13)];
        [_detailLabel lz_rightAlignment];
    }
    return _detailLabel;
}
@end
